/*
 * @Author: dadadaXU 1413107032@qq.com
 * @Date: 2025-02-03 20:04:14
 * @LastEditors: dadadaXU 1413107032@qq.com
 * @LastEditTime: 2025-02-03 20:26:23
 * @FilePath: \LeetCode\680.验证回文串-ii.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=680 lang=cpp
 *
 * [680] 验证回文串 II
 */

#include <string>
#include <iostream>

// @lc code=start
class Solution
{
public:
    inline bool isPalindrome(const std::string &s, int i, int j)
    {
        while (i < j)
        {
            if (s[i] != s[j])
                return false;
            i++;
            j--;
        }
        return true;
    }

    bool validPalindrome(std::string s)
    {
        int i = 0, j = s.size() - 1;
        while (i < j)
        {
            if (s[i] != s[j]) // 跳过字符之后为回文串
                return (isPalindrome(s, i, j - 1) || isPalindrome(s, i + 1, j));

            i++;
            j--;
        }
        return true;
    }
};
// @lc code=end

int main(void)
{
    Solution solution;
    std::cout << solution.validPalindrome("abc") << std::endl;

    return 0;
}